﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data;
using PWS.Entities;

namespace PWS.DAL
{
    public class AccessoriesAccess
    {
        private static Accessories AccessoriesFields(DataRow Row)
        {
            Accessories a = new Accessories();
            a.AccId = (int)Row["fldAccId"];
            a.AccName = Row["fldAccName"] as string;
            a.AccPrice = (decimal)Row["fldAccPrice"];
            return a;
        }
        private static Accessories[] DataSetToAccessoriesArray(DataSet ds4)
        {
            Accessories[] accessories= new Accessories[ds4.Tables[0].Rows.Count];
            for (int i = 0; i < ds4.Tables[0].Rows.Count; ++i)
            {
                accessories[i] = AccessoriesFields(ds4.Tables[0].Rows[i]);
            }
            return accessories;
        }
        public static Accessories[] GetAccessories()
        {
            DataSet ds4 = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["PineDB"].ConnectionString, "Accessories_Get_Accessories");
            return DataSetToAccessoriesArray(ds4);
        }
        

    }

}
